<!--  -->
<template>
  <el-container>
    <el-header style="background-color:#eff2f7" class="top">
      <el-breadcrumb separator="/">
        <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item :to="{ path: '/addminList' }">数据管理</el-breadcrumb-item>
        <el-breadcrumb-item>管理员列表</el-breadcrumb-item>
      </el-breadcrumb>
      <div class="block">
        <el-avatar :size="50" :src="circleUrl"></el-avatar>
        <div class="poputs">
          <div @click="tzHome">首页</div>
          <div @click="tzLogin">退出</div>
        </div>
      </div>
    </el-header>
    <el-main style="background-color:#ffffff" class="main">
      <template>
        <el-table :data="tableData" style="width: 100%">
          <el-table-column prop="create_time" label="日期" width="180"></el-table-column>
          <el-table-column prop="user_name" label="姓名" width="180"></el-table-column>
          <el-table-column prop="city" label="地址"></el-table-column>
          <el-table-column prop="admin" label="权限"></el-table-column>
        </el-table>
      </template>
    <el-pagination
      class="page"
      background
      layout="total,prev, pager, next"
      :total="50000"
      @size-change="handleSizeChange()"
      @current-change="handleCurrentChange"
      :current-page="currentPage1"
      :page-size="20"
    ></el-pagination>
    </el-main>
  </el-container>
</template>

<script>
export default {
  data: function () {
    return {
      circleUrl: "https://img01.sogoucdn.com/app/a/100520093/fb41c7c77a2454f7-01eba5833e7e38bc-11cc0200d4b834a0dddb28091fd46806.jpg",
      tableData: [
        {
          date: "",
          name: "",
          address: "",
        },
      ],
      offset: 0,
      limit: 20,
      currentPage1: 1,
    };
  },
  methods: {
    handleSizeChange() {
      console.log(`每页 ${val} 条`);
    },
    tzHome(){
      this.$router.push({path:'/home'});
    },
    tzLogin(){
      this.$router.push({path:'/login'});
    },
    handleCurrentChange(val) {
      this.tableData = [];
      this.$axios
        .get(
          `https://elm.cangdu.org/admin/all?offset=${
            (val - 1) * this.limit
          }&limit=20`
        )
        .then((res) => {
          this.tableData = res.data.data;
          console.log(`当前页: ${val}`);
        });
    },
  },
  mounted() {
    this.$axios
      .get("https://elm.cangdu.org/admin/all?offset=0&limit=20")
      .then((res) => {
        this.tableData = res.data.data;
        console.log(this.tableData);
      });
  },
};
</script>
<style  scoped>
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 15px;
  font-size: 14px;
}
.page {
  margin: 20px;
  /* margin-bottom: 30px; */
}
.block {
  position: relative;
}
.poputs {
  position: absolute;
  top: 55px;
  left: -20px;
  width: 80px;
  height: 60px;
  background-color: #fff;
  box-sizing: border-box;
  box-shadow: 2px 3px 10px -1px #333;
  display: none;
  z-index: 999;
}
.block:hover .poputs {
  display: block;
}
.poputs > div {
  width: 80px;
  height: 30px;
  line-height: 30px;
  text-align: center;
  color: #000;
  cursor: pointer;
}
.poputs > div:hover {
  background-color: #e4e8f1;
  color: #333;
}

</style>